/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gestionnaires;

import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import modeles.LigneCommande;

/**
 *
 * @author Christian
 */
@Stateless
public class GestionnaireLigneCommande {

    @PersistenceContext
    private EntityManager em;
    
    
     public Collection<LigneCommande> getAllLignesCommandes() {
        Query q = em.createQuery("select o from LigneCommande o", LigneCommande.class);
        return q.getResultList();
    }
     
    public LigneCommande getLigneCommandeById(int id) {
        Query q = em.createQuery("select o from LigneCommande o where o.id=" + id, LigneCommande.class);
        if(q.getResultList().size() <= 0) return null;
        return (LigneCommande) q.getResultList().get(0);
    }
    
}
